using System;
using System.Collections.Generic;
using System.Text;
using Blazing.BusinessObjects.Cms;

using NUnit.Framework;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using TestCleanup = NUnit.Framework.TearDownAttribute;
using ClassInitialize = NUnit.Framework.TestFixtureSetUpAttribute;
using ClassCleanup = NUnit.Framework.TestFixtureTearDownAttribute;


namespace BusinessObjectTests
{
    [TestClass]
    public class StatisticSessionTests : NHibernateInMemoryTestFixtureBase
    {
        private void CheckValues(StatisticSession obj, StatisticSession newObj)
        {
            Assert.AreEqual(obj.ID, newObj.ID);
            Assert.AreEqual(obj.IpAddress, newObj.IpAddress);
            Assert.AreEqual(obj.SessionKey, newObj.SessionKey);
            Assert.AreEqual(obj.OperatingSystem.ID, newObj.OperatingSystem.ID);
            Assert.AreEqual(obj.Useragent.ID, newObj.Useragent.ID);
            Assert.AreEqual(obj.Visitor.ID, newObj.Visitor.ID);
            Assert.AreEqual(obj.RowStamp, newObj.RowStamp);
        }

        [TestMethod]
        public void CreateStatisticSession()
        {
            StatisticSession obj = BusinessObjectFactory.CreateAndFillSession();
            obj.OperatingSystem = BusinessObjectFactory.CreateAndFillStatisticOperatingSystem();
            obj.Useragent = BusinessObjectFactory.CreateAndFillUseragent();
            obj.Visitor = BusinessObjectFactory.CreateAndFillVisitor();

            obj.Save();

            StatisticSession obj2 = StatisticSession.Load(obj.ID);

            Assert.IsNotNull(obj2);

            CheckValues(obj, obj2);

            obj.Delete();
            obj.Save();
        }
    }
}
